#!/bin/bash
#FOR QUESTIONS WRITE mailto:mvona@arb.ca.gov
#-------------------------------------------------------------
#read config file
while read line; do
eval $line
done < Config/config

#read and store the list or drivers
#list all folders in resources labelled *drv (shows available instruments)
drv_folders=$(ls resources | grep drv)


#counter
count_drv=1
for i in $drv_folders
do
    drv_list[$count_drv]="$i"
    count_drv=`expr $count_drv + 1`
    max_count_drv="$count_drv"

done
cat Data/errors* | sort > .tmpstats
num_error=$(wc -l .tmpstats)

#Counter
initial=0
pointer=0
while read error
do
error=$(echo $error | awk '{ print $1 $2 $3 $4 }') 
		if [ "$error" != "$initial" ]; then
			pointer=`expr 1+0`
			errors[$pointer]=$error
			initial=$error
		fi
		if [ "$error" == "$initial" ]; then
			pointer=`expr $pointer + 1`
			errors[$pointer]=$error
			initial=$error
		fi		
						
done < .tmpstats
cnt=${#errors[@]}
echo "Number of elements: $cnt"
for (( i = 0 ; i < cnt ; i++ ))
	do
    		echo "Element [$i]: ${errors[$i]}"
	done
    
 